import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';
import {
  Table,
  Icon,
  Divider,
  Form,
  Select,
  DatePicker,
  Input,
  Card,
  Tag,
  Avatar,
  Checkbox,
  Rate,
  Progress,
  Button,
  message,
  Row,
  Col,
  Modal,
  Collapse,
  List,
  Radio,
} from 'antd';

import styles from './IdentityVerify.less';
import DescriptionList from 'components/DescriptionList';

@connect(({ risk, apply }) => ({
  risk,
  apply,
}))
export default class PbcVerify extends PureComponent {
  constructor(props) {
    super(props);
  }

  state = {
    modalVisible: false,
    riskBankList: null,
    bankNameValue: '',
    antiFraudVerifyVisible: null,
    creditReportingDetails: null,
  };

  componentDidMount() {
    const { dispatch } = this.props;
    const { item } = this.props;
    this.setState({
      antiFraudVerifyVisible: this.props.antiFraudVerifyVisible,
      creditReportingDetails: item,
    });

    dispatch({
      type: 'risk/getCreditResult',
      payload: {
        projectId: item.projectId,
        customerId: item.customerId,
      },
    });
  }

  handleCreditState = item => {
    switch (item.creditVerify) {
      case 0:
        return (
          <div style={{ align: 'center' }}>
            <Tag color="green">未查</Tag>
          </div>
        );
      case 1:
        return (
          <div style={{ align: 'center' }}>
            <Tag color="green">正常</Tag>
          </div>
        );
      case 2:
        return (
          <div style={{ align: 'center' }}>
            <Tag color="orange">关注</Tag>
          </div>
        );
      case 3:
        return (
          <div style={{ align: 'center' }}>
            <Tag color="red">建议禁入</Tag>
          </div>
        );
      case 4:
        return (
          <div style={{ align: 'center' }}>
            <Tag color="blue">查询中</Tag>
          </div>
        );
    }
  };

  render() {
    const { risk: { riskCreditDate } } = this.props;

    return (
      <div>
        {riskCreditDate && (
          // <Modal title="人行征信" {...this.props}>
          <Card actions={[this.handleCreditState(riskCreditDate)]}>
            <Card.Meta
              description={
                <div>
                  <p>{riskCreditDate.creditNote}</p>
                </div>
              }
            />
          </Card>
        )}
      </div>
    );
  }
}
